Micron Document
🎖️GitЯра🎖️

Node / meshtastic / Meshtastic-Android / files / core / common / src / jvmMain / kotlin / org / meshtastic / core / common / log / InMemoryLogBuffer.kt

Displaying Raw • Download

core/common/src/jvmMain/kotlin/org/meshtastic/core/common/log/InMemoryLogBuffer.kt bd2863243bab6eb213401d949839a2bc74dde7e2 (bd286324) Text, 2.03 KB

T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.common.log

Tff7b72import T7ee787co.touchlab.kermit.LogWriter
Tff7b72import T7ee787co.touchlab.kermit.Severity

T8b949e/**
* A bounded in-memory ring buffer of recent Kermit log lines. Desktop has no system logcat, so install this writer at
* startup (`Logger.setLogWriters(platformLogWriter(), InMemoryLogBuffer)`) to let the Debug screen view and export the
* app's own logs. Lines are formatted to loosely match Android's `logcat -v time` shape (`L/tag: message`) so the same
* viewer/filters work on both platforms.
*/
Tff7b72object T56d364InMemoryLogBuffer Tb4b4b4: Te6edf3LogWriterTb4b4b4(Tb4b4b4) Tb4b4b4{
Tff7b72private Tff7b72const Tff7b72val Te6edf3MAX_LINES Tff7b72= T79c0ff5T79c0ff0T79c0ff0T79c0ff0
Tff7b72private Tff7b72val Te6edf3lines Tff7b72= Te6edf3ArrayDequeTff7b72<Tffa657StringTff7b72>Tb4b4b4(Tb4b4b4)

Tff7b72override Tff7b72fun Td2a8fflogTb4b4b4(Te6edf3severityTb4b4b4: Te6edf3SeverityTb4b4b4, Te6edf3messageTb4b4b4: Tffa657StringTb4b4b4, Te6edf3tagTb4b4b4: Tffa657StringTb4b4b4, Te6edf3throwableTb4b4b4: Te6edf3Throwable?Tb4b4b4) Tb4b4b4{
Tff7b72val Te6edf3line Tff7b72= Te6edf3buildString Tb4b4b4{
Te6edf3appendTb4b4b4(Te6edf3severityTb4b4b4.Te6edf3nameTb4b4b4.Te6edf3firstTb4b4b4(Tb4b4b4)Tb4b4b4) T8b949e// V/D/I/W/E/A — matches the viewer's level filter
Te6edf3appendTb4b4b4(Ta5d6ff'/'Tb4b4b4)
Te6edf3appendTb4b4b4(Te6edf3tagTb4b4b4)
Te6edf3appendTb4b4b4(Ta5d6ff"Ta5d6ff: Ta5d6ff"Tb4b4b4)
Te6edf3appendTb4b4b4(Te6edf3messageTb4b4b4)
Tff7b72if Tb4b4b4(Te6edf3throwable Tff7b72!Tff7b72= Tff7b72nullTb4b4b4) Tb4b4b4{
Te6edf3appendTb4b4b4(Ta5d6ff'\n'Tb4b4b4)
Te6edf3appendTb4b4b4(Te6edf3throwableTb4b4b4.Te6edf3stackTraceToStringTb4b4b4(Tb4b4b4)Tb4b4b4)
Tb4b4b4}
Tb4b4b4}
Te6edf3synchronizedTb4b4b4(Te6edf3linesTb4b4b4) Tb4b4b4{
Te6edf3linesTb4b4b4.Te6edf3addLastTb4b4b4(Te6edf3lineTb4b4b4)
Tff7b72while Tb4b4b4(Te6edf3linesTb4b4b4.Te6edf3size Tff7b72> Te6edf3MAX_LINESTb4b4b4) Te6edf3linesTb4b4b4.Te6edf3removeFirstTb4b4b4(Tb4b4b4)
Tb4b4b4}
Tb4b4b4}

Tff7b72fun Td2a8ffsnapshotTb4b4b4(Tb4b4b4)Tb4b4b4: Tffa657String Tff7b72= Te6edf3synchronizedTb4b4b4(Te6edf3linesTb4b4b4) Tb4b4b4{ Te6edf3linesTb4b4b4.Te6edf3joinToStringTb4b4b4(Ta5d6ff"Ta5d6ff\Ta5d6ffnTa5d6ff"Tb4b4b4) Tb4b4b4}
Tb4b4b4}

Served by rngit 1.5.0 - Generated in 0.04s